package com.gxa.k12.course.controller;


import com.gxa.k12.common.util.PageUtils;
import com.gxa.k12.common.util.R;
import com.gxa.k12.course.entity.CourseDescriptionEntity;
import com.gxa.k12.course.service.CourseDescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 课程简介
 *
 * @author wenjie
 * @email wenj73487@gmail.com
 * @date 2021-07-20 11:28:11
 */
@RestController
@RequestMapping("course/coursedescription")
public class CourseDescriptionController {
    @Autowired
    private CourseDescriptionService courseDescriptionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("course:coursedescription:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = courseDescriptionService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    // @RequiresPermissions("course:coursedescription:info")
    public R info(@PathVariable("id") String id) {
            CourseDescriptionEntity courseDescription = courseDescriptionService.getById(id);
        return R.ok().put("courseDescription", courseDescription);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("course:coursedescription:save")
    public R save(@RequestBody CourseDescriptionEntity courseDescription) {
            courseDescriptionService.save(courseDescription);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("course:coursedescription:update")
    public R update(@RequestBody CourseDescriptionEntity courseDescription) {
            courseDescriptionService.updateById(courseDescription);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("course:coursedescription:delete")
    public R delete(@RequestBody String[] ids) {
            courseDescriptionService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
